home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / programming / e / lsestuff / mythread.e < prev    next >
Text File  |  1999-11-29  |  851b  |  44 lines

  1. OPT MODULE
  2.  
  3. MODULE 'dos/dos'
  4. MODULE 'dos/dostags'
  5. MODULE 'geta4'
  6. MODULE 'utility/tagitem'
  7.  
  8. DEF proc2bethread, mother
  9.  
  10. EXPORT PROC birth(proc, name, pri=0, tags=NIL)
  11.    DEF mythread
  12.    /* setting the global */
  13.    proc2bethread:=proc
  14.    /* store A4 */
  15.    storea4()
  16.    /* save mothertask for possible use... */
  17.    mother:=FindTask(0)
  18.    /* the usual...*/
  19.    mythread:=CreateNewProc(
  20.     [
  21.     NP_ENTRY,{threadstart}, -> where the thread process begins
  22.     NP_NAME, name,
  23.     NP_PRIORITY, pri,
  24.     IF tags = NIL THEN TAG_END ELSE TAG_MORE,
  25.     tags
  26.     ])
  27.    IF mythread THEN waitCTRL_F()
  28. ENDPROC mythread
  29.  
  30. PROC threadstart()
  31.    geta4()
  32.    proc2bethread(mother)
  33. ENDPROC
  34.  
  35. EXPORT PROC cutstring(mama) IS signalCTRL_F(mama)
  36.  
  37. EXPORT PROC signalCTRL_F(task)
  38.    Signal(task, SIGBREAKF_CTRL_F)
  39. ENDPROC
  40.  
  41. EXPORT PROC waitCTRL_F()
  42.    Wait(SIGBREAKF_CTRL_F)
  43. ENDPROC
  44.